<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page session="false" %>
<%@ page isELIgnored ="false" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>

<script type="text/javascript">
//<![CDATA[
(function(){
	dojo.byId("lbl_calendar_edit_affair").innerHTML = Organization._resource.affair ;
	$kdom.appendDojoProp("input_calendar_edit_affair","missingMessage",$ksub(KppModule.commonResource.missingMessage,[Organization._resource.organizationCode]));
	dojo.byId("lbl_calendar_edit_begindate").innerHTML = Organization._resource.beginDate;
	dojo.byId("lbl_calendar_edit_enddate").innerHTML = Organization._resource.endDate;
	dojo.byId("lbl_calendar_edit_monday").innerHTML = Organization._resource.monday;
	dojo.byId("lbl_calendar_edit_tuesday").innerHTML = Organization._resource.tuesday;
	dojo.byId("lbl_calendar_edit_wednesday").innerHTML = Organization._resource.wednesday;
	dojo.byId("lbl_calendar_edit_thursday").innerHTML = Organization._resource.thursday;
	dojo.byId("lbl_calendar_edit_friday").innerHTML = Organization._resource.friday;
	dojo.byId("lbl_calendar_edit_saturday").innerHTML = Organization._resource.saturday;
	dojo.byId("lbl_calendar_edit_sunday").innerHTML = Organization._resource.sunday;
	$kdom.appendDojoProp("btn_calrule_edit_save","label",KppModule.commonResource.save);
	$kdom.appendDojoProp("btn_calrule_edit_cancel","label",KppModule.commonResource.cancel);
	if("${calendar.sunday}"=="true"){
		$kdom.appendDojoProp("input_calendar_edit_sunday","checked","true");
	}
	if("${calendar.monday}"=="true"){
		$kdom.appendDojoProp("input_calendar_edit_monday","checked","true");
	}
	if("${calendar.tuesday}"=="true"){
		$kdom.appendDojoProp("input_calendar_edit_tuesday","checked","true");
	}
	if("${calendar.wednesday}"=="true"){
		$kdom.appendDojoProp("input_calendar_edit_wednesday","checked","true");
	}
	if("${calendar.thursday}"=="true"){
		$kdom.appendDojoProp("input_calendar_edit_thursday","checked","true");
	}
	if("${calendar.friday}"=="true"){
		$kdom.appendDojoProp("input_calendar_edit_friday","checked","true");
	}
	if("${calendar.saturday}"=="true"){
		$kdom.appendDojoProp("input_calendar_edit_saturday","checked","true");
	}
})();

function dialogShow(dlgId,content) {
	this.dlg=dijit.byId(dlgId);
	if(!this.dlg)this.dlg=new dijit.Dialog({
		id:dlgId,
		title: KppModule.commonResource.hint,
		style: "padding:0px;width:300px;height:100px;background-color:#FFF;"});
		this.dlg.set("content","<div style=\"padding:20px;text-align:center\">"+content+"</div>");
	this.dlg.show();
}

function dateCompare() {
	var startTime = dijit.byId("input_calendar_edit_begindate").getValue();
	var endTime = dijit.byId("input_calendar_edit_enddate").getValue();
	if(startTime != null && endTime != null ){
		if(Date.parse(startTime)<Date.parse(endTime)){
			dijit.byId("btn_calrule_edit_save").setDisabled(false);
		} else {
			dijit.byId("btn_calrule_edit_save").setDisabled(true);
			dialogShow("calrule_edit_dateWarn",Organization._resource.dateWarn);
		};
	}
}

//]]>
</script>
<span style="display:none">To solve IE7/8 script event tag problem.</span>
<div data-dojo-type="dijit.form.Form" data-dojo-props="action:'../../organization/calendar/editrule.do?cid=${calendar.id}',id:'frm_calendar_role_edit'">
	<table width="100%" cellspacing="10">
		<tr>
			<td><label id="lbl_calendar_edit_affair">calendar rule affair</label></td>
			<td colspan="7" ><input id="input_calendar_edit_affair" data-dojo-type="dijit/form/ValidationTextBox" value="${calendar.affair}" data-dojo-props="required:true,trim:true,name:'affair',maxLength:20"></input></td>
		</tr>
		<tr>
			<td><label id="lbl_calendar_edit_begindate">calendar rule begin date</label></td>
			<td colspan="7"><input id="input_calendar_edit_begindate" data-dojo-type="dijit/form/DateTextBox" value="${calendar.beginDate}" data-dojo-props="required:true,name:'beginDate',onBlur:dateCompare"></input></td>
		</tr>
		<tr>
			<td><label id="lbl_calendar_edit_enddate">calendar rule end date</label></td>
			<td colspan="7"><input id="input_calendar_edit_enddate" data-dojo-type="dijit/form/DateTextBox" value="${calendar.endDate}" data-dojo-props="required:true,name:'endDate',onBlur:dateCompare"></input></td>
		</tr>
		<tr>
			<td><label id="lbl_calendar_edit_monday">Monday</label><input id="input_calendar_edit_monday" data-dojo-type="dijit/form/CheckBox" data-dojo-props="required:true,name:'monday'"></input></td>
			<td><label id="lbl_calendar_edit_tuesday">Tuesday</label><input id="input_calendar_edit_tuesday" data-dojo-type="dijit/form/CheckBox" data-dojo-props="required:true,name:'tuesday'"></input></td>
			<td><label id="lbl_calendar_edit_wednesday">Wednesday</label><input id="input_calendar_edit_wednesday" data-dojo-type="dijit/form/CheckBox" data-dojo-props="required:true,name:'wednesday'"></input></td>
			<td><label id="lbl_calendar_edit_thursday">Thursday</label><input id="input_calendar_edit_thursday" data-dojo-type="dijit/form/CheckBox" data-dojo-props="required:true,name:'thursday'"></input></td>
			<td><label id="lbl_calendar_edit_friday">Friday</label><input id="input_calendar_edit_friday" data-dojo-type="dijit/form/CheckBox" data-dojo-props="required:true,name:'friday'"></input></td>
			<td><label id="lbl_calendar_edit_saturday">Saturday</label><input id="input_calendar_edit_saturday" data-dojo-type="dijit/form/CheckBox" data-dojo-props="required:true,name:'saturday'"></input></td>
			<td><label id="lbl_calendar_edit_sunday">Sunday</label><input id="input_calendar_edit_sunday" data-dojo-type="dijit/form/CheckBox" data-dojo-props="required:true,name:'sunday'"></input></td>
		</tr>
	</table>
</div>
<div class="dialogFooter">
	<div id="btn_calrule_edit_save" data-dojo-type="dijit.form.Button" data-dojo-props="iconClass:'dijitEditorIcon dijitEditorIconSave', showLabel:true" style="width:70px;">
		<script type="dojo/on" data-dojo-event="click" data-dojo-args="evt">
			var options={
								domain:Organization._resource.rule,
								refresh:Calendar.ruleRefresh,
								button:this,
								dialogId:"dialog_org_calrule_edit",
								formId:"frm_calendar_role_edit",
								resource:Organization._resource
						};
			KppModule.restProxy(options).putUpdate();
		</script>
	</div>
	<div id="btn_calrule_edit_cancel" data-dojo-type="dijit.form.Button" data-dojo-props="iconClass:'dijitEditorIcon dijitEditorIconUndo', showLabel:true" style="width:70px;">
		<script type="dojo/on" data-dojo-event="click" data-dojo-args="evt">
				dijit.byId("dialog_org_calrule_edit").hide();
		</script>
	</div>
</div>